<template>
  <div>
    <el-form label-width="80px" :rules="rules" :model="phone" ref="formRef">
      <el-form-item label="手机号" prop="num">
        <el-input v-model="phone.num"></el-input>
      </el-form-item>
      <el-form-item label="验证码" prop="code">
        <div class="get-code">
          <el-input v-model="phone.code"></el-input>
          <el-button type="primary" class="getBtn">获取验证码</el-button>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts" setup>
import { reactive, ref, defineExpose } from 'vue'
import { ElForm } from 'element-plus'

import { rules } from '../config/account-config'

const formRef = ref<InstanceType<typeof ElForm>>()
const phone = reactive({
  num: '',
  code: ''
})

const phoneRef = (isKeepPassword: boolean) => {
  formRef.value?.validate((valid) => {
    console.log(valid, isKeepPassword)
  })
}
defineExpose({
  phoneRef
})
</script>

<style scoped lang="less">
.get-code {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.getBtn {
  margin-left: 8px;
}
</style>
